package java_DesignPattern.SixPrinciple.DependencyInversionPrinciple.SpringImpl;

import java_DesignPattern.SixPrinciple.DependencyInversionPrinciple.My2.AssembleComputer;

/**
 * 电脑类
 */
public class Computer{

    //电脑组件
    private CPU cpu;
    private Memory memory;
    private HardDisk hardDisk;

    public Computer() {
    }

     //设置电脑组件方法
    public Computer(CPU cpu, Memory memory, HardDisk hardDisk) {
        this.cpu = cpu;
        this.memory = memory;
        this.hardDisk = hardDisk;
    }

     //运行电脑方法
    public void run(){
        cpu.run();
        memory.read("数据");
        memory.save("数据");
        hardDisk.read("数据");
        hardDisk.save("数据");
    }
}
